#!/usr/bin/perl
use POSIX qw/strftime/;
my $p = "/home/www/www.onetipp.com/img/";
my $l = "/home/sqlbackup_root/logfile_pngquant.txt";
use File::Find;
find(\&wanted, $p);
sub wanted {
	my $file = $File::Find::name;
	if (-e $file && -f $file){
		print "pngquant --quality=65-88 --speed 1 $file -o $file --force\n";
		#system("pngquant --quality=70-90 --speed 1 $file -o $file --ext= --force");
		system("pngquant --quality=55-68 --speed 1 $file -o $file --force");
		
		system("chmod -R 755 $file");
		system("chown -R www-data:www-data $file");

		open(W,"+>>$l");
		$t = localtime;
		print time() . " ) -$t-: pngquant --quality=65-88 --speed 1 $file -o $file --force\n";
		close W;
	};
}
system("chmod -R 755 $p");
system("chown -R www-data:www-data $p");